#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 2e5 + 10;

int fa[N],siz[N],rt,son[N],n,bsiz,cent,stk[N],top;
ll d[N],w[N];
bool vis[N];
ll ans;
struct edge {int u,v;ll w;};
vector <pii> G[N];
vector <edge> e;
bool operator < (edge a,edge b) { return a.w < b.w;}

void getrt(int x,int p) {
	siz[x] = 1; son[x] = 0;
	for(auto d : G[x]) if(d.fi ^ p && !vis[d.fi]) getrt(d.fi,x),siz[x] += siz[d.fi],son[x] = max(son[x],siz[d.fi]);
	son[x] = max(son[x],bsiz - siz[x]); if(rt == 0 || son[x] < son[rt]) rt = x;
}

void calc(int x,int p,ll dis) {
	siz[x] = 1; d[x] = dis; for(auto d : G[x]) if(d.fi ^ p && !vis[d.fi]) calc(d.fi,x,dis + d.se),siz[x] += siz[d.fi];
	stk[++top] = x; if(cent == 0 || w[x] + d[x] < w[cent] + d[cent]) cent = x;
}

void Divide(int x,int tsiz) {
	rt = 0; bsiz = tsiz; getrt(x,0); x = rt; vis[x] = 1;
	cent = 0; calc(x,0,0); while(top) e.pb((edge){cent,stk[top],d[stk[top]] + w[stk[top]] + d[cent] + w[cent]}) , top--;
	for(auto d : G[x]) if(!vis[d.fi]) Divide(d.fi,siz[d.fi]);
}

int gf(int x) {return fa[x] == x ? x : fa[x] = gf(fa[x]);}

bool merge(int x,int y) {
	x = gf(x); y = gf(y); if(x == y) return 0;
	return fa[x] = y,1;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1;i <= n;i++) w[i] = in;
	for(int i = 1,u,v,w;i < n;i++) u = in,v = in,w = in,G[u].pb(pii(v,w)),G[v].pb(pii(u,w));
	Divide(1,n); for(int i = 1;i <= n;i++) fa[i] = i;
	sort(e.begin(),e.end()); int cnt = 0;
	for(auto d : e) 
		if(merge(d.u,d.v)) ans += d.w,cnt++;
	printf("%lld\n",ans);
	return 0;
}
